import os
try:
    from .accuracy_mask import evaluation as eval_rectangle_map
    from .accuracy_mask_iou import eval_polygon_map
except:
    from accuracy_mask import evaluation as eval_rectangle_map
    from accuracy_mask_iou import eval_polygon_map

def evaluation(gtsrc, ptsrc, mode='polygon', xls=None):
    assert mode in ('rectangle', 'polygon'), 'mode must be "rectangle" or polygon'
    if xls in ('', None):
        xls = os.path.join(ptsrc, 'evaluation.xlsx')
    if mode == 'rectangle':
        eval_rectangle_map(gtsrc, ptsrc, result=xls, iou='standard', print_summary=True)
    else:
        eval_polygon_map(gtsrc, ptsrc, iouthr=0.5, xls=xls)

if __name__ == '__main__':
    ptsrc = r'G:\data\datasets\drink\daiding_101\base_test\yy\queryinst_swin_tiny_mask_bottle'
    gtsrc = r'G:\data\datasets\drink\daiding_101\base_test\yy'    
    evaluation(gtsrc, ptsrc, mode='rectangle', xls=None)